//
//  Localization.h
//  client
//
//  Created by DuanHongbo on 15/12/22.
//
//

#ifndef Localization_h
#define Localization_h

#include <stdio.h>
#include <string>
#include <map>
#include <unordered_map>


class Localization{
public:
    typedef std::unordered_map<std::string,std::string> StringDict;
    static Localization* getInstance();
    static void destoryInstance();
public:
    void setLanguage(const char* lg);
    const std::string getAppDefaultLang();
    const std::string getUserSelectLang();
    std::string initLanguage();
    void initWithSqlite(const char* filePath);
    void initWithJson(const std::string& content);
    const std::string& getStr(const std::string& key,const std::string& def);
    const std::string& getStr(const std::string& key);
    void clearCaches();
private:
    void destory();
private:
    std::string _language;
    StringDict _cachedMap;
};

#define L10NSTR(k) Localization::getInstance()->getStr(k)


#endif /* Localization_h */
